package com.cw.demo.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.dubbo.rpc.service.GenericService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson2.JSON;
import com.cw.framework.handle.DubboGenericServiceHandle;

import lombok.extern.slf4j.Slf4j;

/**
 * TODO
 *
 * @author chenw
 * @date 2021/11/11
 */
@RestController
@RequestMapping("")
@Slf4j
public class DemoController{
    @Autowired
    private DubboGenericServiceHandle dubboGenericServiceHandle;
    @RequestMapping("/testDubboService")
    public void testDubboService() {
        GenericService query = dubboGenericServiceHandle.getGenericService("hrkj-demo-center",
            "com.cw.demo.api.DemoApi", "1.0.0");
        Map paramMap = new HashMap();
        paramMap.put("name","chenw");
        Object object = query.$invoke("sayHello", new String[] {"java.lang.String"},
            new Object[] {paramMap});
        log.info(JSON.toJSONString(object));
    }
}
